<?php
/**
 * 用户总数模型
 */
class LeaveTotalModel extends Model {
    public function  __construct() {
        parent::__construct();
    }

    /**
     * 添加一个Total记录
     * @param <type> $user_id
     * @param <type> $type
     * @param <type> $total
     * @param <type> $remain 
     */
    public function insertUserTotal($user_id,$type,$total,$remain,$first_name,$last_name){
        $data=array(
            'user_id'=>$user_id,
            'type'=>$type,
            'total'=>$total,
            'remain'=>$remain,
            'first_name'=>$first_name,
            'last_name'=>$last_name
        );
        $this->add($data);
    }


    public function getLeaveTotalRemain($page_size,$orderby='user_id ASC',$sqlwhere=''){
        import("ORG.Util.Page");
        $count = $this->where("1=1".$sqlwhere)->count();
        $Page = new Page($count,$page_size);
        $show = $Page->show();
        $list = $this->where("1=1".$sqlwhere)->order($orderby)->limit($Page->firstRow.','.$Page->listRows)->select();
        return array($show,$list,$count);
    }
}

?>